'use strict';
const {
    Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
    class Article extends Model {
        /**
         * Helper method for defining associations.
         * This method is not a part of Sequelize lifecycle.
         * The `models/index` file will call this method automatically.
         */
        static associate(models) {
            models.Article.belongsTo(models.Cate, {
                foreignKey: 'cate_id'
            })
        }
    }
    Article.init({
        title: DataTypes.STRING,
        pictrue: DataTypes.TEXT,
        cate_id: DataTypes.INTEGER,
        content: DataTypes.TEXT,
        author: DataTypes.STRING,
        add_time: DataTypes.DATE,
        view_nums: DataTypes.INTEGER,
        is_del: DataTypes.INTEGER
    }, {
        sequelize,
        modelName: 'Article',
    });
    return Article;
};